<template>
  <div class="classify">
    <!-- <h1>This is an about page</h1> -->
    <div class="header">
      <h3>商品分类</h3>
    </div>
    <div class="content">
      <!-- 左边的列表 -->
      <div class="leftbox">
        <div class="left">
          <van-sidebar v-model="activeKey" @change="onChange">
            <van-sidebar-item
              v-for="(item, index) in classifylist"
              :key="index"
              :title="item"
            />
          </van-sidebar>
        </div>
      </div>

      <!-- 右边的商品 -->
      <div class="right">
        <div
          class="item"
          @click="getDetail(item.id)"
          v-for="item in goodslist"
          :key="item.id"
        >
          <div class="item-center">
            <div class="left">
              <img :src="item.src" alt="" />
            </div>
            <div class="right">
              <div class="msg">
                <div class="van-multi-ellipsis--l2">
                  {{ item.goodmsg }}
                </div>
              </div>
              <div class="canshu">单价:￥{{ item.goodprice }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="footer"></div>
  </div>
</template>
<style lang="scss" scoped>
$maincolor: "#c1ab96";

.classify {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
}
.header {
  margin-top: -20px;
  font-size: 20px;
  color: white;
  height: 120px;
  background-color: #c1ab96;
  text-align: left;
  padding: 10px;
  h3 {
    position: relative;
    top: 50px;
  }
}
.footer {
  height: 70px;
}
.content {
  flex: 1;
  // height: ;
  overflow: scroll;
  display: flex;
  .leftbox {
    width: 77px;
    overflow: hidden;
    .left {
      height: 100%;
      overflow-y: scroll;
      position: fixed;
    }
  }

  .right {
    // height: 100vh;
    // width: calc(100vh-120px);
    flex: 1;
    .item {
      padding: 15px 10px;
      .item-center {
        height: 100px;
        // background-color: $main;
        display: flex;
        justify-content: space-around;
        .left {
          width: 100px;
          height: 100%;
          overflow: hidden;
          border-radius: 8px;
          margin-right: 15px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .right {
          font-size: 14px;
          width: 170px;
          .msg {
            height: 40px;
          }
          .canshu {
            margin-top: 5px;
            padding-left: 5px;
            height: 50px;
            background-color: rgba(248, 248, 248, 1);
            color: #999999;
            text-align: left;
            line-height: 50px;
          }
        }
      }
    }
  }
}
</style>

<script>
// import { Notify } from "vant";
import goodsModel from "../model/goodsModel";
export default {
  data() {
    return {
      activeKey: 0,
      classifylist: ["饰品", "上衣", "鞋子"],
      goodslist: [],
      // item1: [],
    };
  },

  created() {
    goodsModel.query({ classify: "饰品" }).then((res) => {
      this.goodslist = res.data;
      console.log(this.goodslist);
      // item1 = this.goodslist.filter;
    });
  },

  methods: {
    onChange(index) {
      // Notify({ type: "primary", message: this.classifylist[index] });
      console.log(this.classifylist[index]);
      let classify = this.classifylist[index];
      goodsModel.query({ classify: classify }).then((res) => {
        this.goodslist = res.data;
        console.log(this.goodslist);
        // item1 = this.goodslist.filter;
      });
    },
    getDetail(id) {
      // console.log(aa);
      this.$router.history.push({
        name: "detail",
        params: { id },
      });
      // this.$router.go(0);
    },
  },
};
</script>
